package com.kgdev.cweb.resmng.config;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigPropetyManager {

	public ConfigPropetyManager() {
		try {
			navigationProperties = getPropertiesFromClasspath();
		} catch (IOException e) {
			System.out.println(e.getMessage());
		}
	}

	private static final String CONFIGURATION_PROPERTIES = "config.properties";
	private Properties navigationProperties;

	private Properties getPropertiesFromClasspath() throws IOException {
		InputStream inputStream = this.getClass().getResourceAsStream(
				CONFIGURATION_PROPERTIES);

		if (inputStream == null) {
			throw new FileNotFoundException("property file '"
					+ CONFIGURATION_PROPERTIES + "' not found in the classpath");
		}
		navigationProperties = new Properties();
		navigationProperties.load(inputStream);
		return navigationProperties;
	}

	public String getString(String key) {
		return navigationProperties.getProperty(key);
	}

}
